package com.zoweunion.mechanic.config;

import java.util.concurrent.Executor;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
 * @Description:  
 * @author: 王春伟 
 * @date:   2019年1月4日 下午3:43:45    
 * @Copyright: 2019 www.zoweunion.com Inc. All rights reserved.
 */
//异步线程池配置
@Configuration
@EnableAsync
public class AsyncConfig implements AsyncConfigurer {

	@Override
	public Executor getAsyncExecutor() {
		
		//定义线程池
		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
		//核心线程数
		taskExecutor.setCorePoolSize(4);
		//线程池最大线程数
		taskExecutor.setMaxPoolSize(8);
		//线程队列最大线程数
		taskExecutor.setQueueCapacity(2000);
		//初始化
		taskExecutor.initialize();
		
		return taskExecutor;
	}
	

}
